![]() |
PATH![]() |
As a rule, Java applets are unaware of other applets; they cannot share information. However, there may be cases where you would want one or more applets to be able to share data. For example, you may have two applets running on an HTML page, one of which queries the user for personal identification, and another which displays information based on the data the user entered. Ideally you would like to have the data input applet be able to provide the personal information to the display applet so the user does not have to enter the information more than once.
In MRJ, Apple provides an abstract construct called an applet page, or simply a page , which allows applets to share data. Within a page you can instantiate multiple AWT contexts and applets. All applets created within a page share the same class loader, so they share the same static variables.
For example, in Figure 1-4, applet 1 and applet 2 can share static data since they are contained within the same applet page. Neither applet 1 nor applet 2 can share data with applet 3, since it is not contained within the applet page.
You must create an applet page after you instantiate a session and before instantiating any AWT contexts for that page. You create a new applet page by calling the
JMNewAppletPage
function.
After creating the applet page, you instantiate AWT contexts within in by calling the
JMNewAWTContextInPage
function rather than
JMNewAWTContext
function. Both functions operate identically, except that
JMNewAWTContextInPage
has an additional parameter to specify the page. You can then instantiate applets within the AWT contexts normally.
After you are finished with an applet page, you must dispose of it using the
JMDisposeAppletPage
function.
Previous | Back Up One Level | Next |